/*
 * @Author: 邱狮杰
 * @Date: 2021-05-15 12:19:56
 * @LastEditTime: 2021-05-15 12:25:56
 * @FilePath: /weddingdress/src/hook/lifeCycle.ts
 * @Description: 生命周期
 */
import { useEffect } from "react";

/**
 * @description 组件挂载时
 * @param { Function } callBack 回调函数
 */
export function useMounted(callBack: () => void) {
  useEffect(() => {
    callBack();
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
}

/**
 * @description 组件卸载时
 * @param { Function } callBack 回调函数
 */
export function useUnload(callBack: () => void) {
  useEffect(() => {
    return () => {
      callBack();
    };
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
}
